/**
 * @author: mattwang@tencent.com
 * @date: 2012-10-13
 */

#ifndef __LR_CORE_H__
#define  __LR_CORE_H__

#include <deque>
#include <vector>
#include <cmath>
#include <iostream>

#include "type_def.h"
#include "mpi_def.h"
#include "pvclick_loader.h"
#include "owlqn.h"
#include "optim_problem.h"

class LRCore: OptimProblem {
public:
	LRCore() {
	}
	~LRCore() {
	}
	int train(PvClickLoader &data_loader);
	int predict(PvClickLoader &data_loader);

	double eval(const DVector& x, DVector& gradient);

private:
	int local_instance_num;
	int global_feature_num;
	std::vector<std::vector<SparseVectorData> > *data_matrix;
	std::vector<PvClick> *data_pvclick;

	DVector init_x;
	DVector optim_x;


	double terminate_criterion;
	double l1_weight;
	double owlqn_c;

	double global_func_value;
	double *local_gradient;
	double *global_gradient;

private:
	OwlqnOptimizer *optimizer;

};

#endif // __LR_CORE_H__
